﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Menu_Dict.aspx.cs" Inherits="KPI_SYSTEM.baseData.Menu_Dict" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>
    <style>
        
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <f:PageManager ID="PageManager1" runat="server" />
        <f:Grid ID="Grid1" IsFluid="true" CssClass="blockpanel" ShowBorder="true" ShowHeader="true" EnableCollapse="false"
            runat="server" DataKeyNames="REC_ID,Menu_Name" AllowCellEditing="false"  
            DataIDField="REC_ID" Title="功能菜单字典" OnRowCommand="Grid1_RowCommand"  OnPreRowDataBound="Grid1_PreRowDataBound">
            <Toolbars>
                <f:Toolbar ID="Toolbar2" Position="Top" runat="server">
                    <Items>
                        <f:Button ID="btnNew" Text="新增" Icon="Add" EnablePostBack="false" runat="server">
                            <Listeners>
                                <f:Listener Event="click" Handler="onNewButtonClick" />
                            </Listeners>
                        </f:Button>
                        <f:Button ID="btnEdit" Text="编辑" Icon="Pencil" EnablePostBack="false" runat="server">
                            <Listeners>
                                <f:Listener Event="click" Handler="onEditButtonClick" />
                            </Listeners>
                        </f:Button>
                        <f:Button ID="btnDelete" Text="删除" Icon="Delete" ConfirmText="确定删除当前数据？" OnClick="btnDelete_Click"
                            runat="server">
                        </f:Button>
                    </Items>
                </f:Toolbar>
            </Toolbars>
            <Columns>
                <f:RenderField Width="150px" ColumnID="Menu_Name" DataField="Menu_Name"
                    HeaderText="菜单名称">
                </f:RenderField>
                <f:RenderField Width="80px" ColumnID="Parent_ID" DataField="Parent_ID" 
                    HeaderText="父级菜单ID" Hidden="true">
                </f:RenderField>
                <f:RenderField Width="150px" ColumnID="ParentName" DataField="ParentName" 
                    HeaderText="父级菜单名称">
                </f:RenderField>
                <f:RenderCheckField  Width="80px" RenderAsStaticField="true" ColumnID="STATUS"  DataField="STATUS"  HeaderText="状态" />
                <f:RenderField Width="100px" ColumnID="ICO_PATH" DataField="ICO_PATH" 
                    HeaderText="图标路径">
                </f:RenderField>
                <f:RenderField Width="150px" ColumnID="CODE_PATH" DataField="CODE_PATH" 
                    HeaderText="页面代码路径">
                </f:RenderField>
                <f:RenderField Width="60px" ColumnID="SEQ_NO" DataField="SEQ_NO" 
                    HeaderText="排序">
                </f:RenderField>
                <f:RenderField Width="150px" ColumnID="REMARK" DataField="REMARK"
                    ExpandUnusedSpace="true" MinWidth="150px" HeaderText="备注">
                </f:RenderField>
                <f:LinkButtonField ColumnID="Edit" Width="50px" EnablePostBack="false"
                    Icon="Pencil" />
                <f:LinkButtonField Width="50px" ConfirmText="删除选中行？" ConfirmTarget="Top"
                    CommandName="Delete" Icon="Delete" />
            </Columns>
        </f:Grid>

        <f:Window ID="Window1" Title="弹出窗体" Hidden="true" EnableIFrame="false"
            EnableMaximize="true" Target="Self" EnableResize="true" runat="server"
            IsModal="true" Width="600px">
            <Items>
                <f:SimpleForm ID="SimpleForm1" runat="server" ShowBorder="false" ShowHeader="false" BodyPadding="10px">
                    <Items>
                        <f:HiddenField ID="hfFormID" runat="server"></f:HiddenField>
                        <f:TextBox ID="tbxFormMenu_Name" ShowRedStar="true" Label="菜单名称" Required="true" runat="server">
                        </f:TextBox>
                        <f:DropDownList ID="ddlFormParentName" Label="父级菜单" AutoSelectFirstItem="false" runat="server">
                        </f:DropDownList>
                        <f:CheckBox ID="cbFormSTATUS" Label="是否启用" runat="server">
                        </f:CheckBox>
                        <f:TextBox ID="tbxFormICO_PATH" Label="图标名称"  runat="server">
                        </f:TextBox>
                        <f:TextBox ID="tbxFormCODE_PATH"  Label="页面代码路径"  runat="server">
                        </f:TextBox>
                        <f:TextBox ID="tbxFormSEQ_NO" Label="排序" Required="true" ShowRedStar="true" runat="server">
                        </f:TextBox>
                         <f:TextArea ID="tbxFormREMARK" Label="备注" runat="server" Height="150px" >
                        </f:TextArea>
                        
                    </Items>
                    <Toolbars>
                        <f:Toolbar ID="Toolbar1" Position="Bottom" ToolbarAlign="Right" runat="server">
                            <Items>
                                <f:Button ID="btnSave"
                                    Icon="SystemSave" runat="server" Text="保存数据" ValidateForms="SimpleForm1" OnClick="btnSave_Click">
                                </f:Button>
                            </Items>
                        </f:Toolbar>
                    </Toolbars>
                </f:SimpleForm>
            </Items>
        </f:Window>
        <br />
        <br />
        <br />
    </form>
     <script>



        var windowClientID = '<%= Window1.ClientID %>';
        var gridClientID = '<%= Grid1.ClientID %>';
        var btnDeleteClientID = '<%= btnDelete.ClientID %>';
        var btnSaveClientID = '<%= btnSave.ClientID %>';

        var formClientID = '<%= SimpleForm1.ClientID %>';
        var hfFormIDClientID = '<%= hfFormID.ClientID %>';
        var tbxFormMenu_NameClientID = '<%= tbxFormMenu_Name.ClientID %>';
        var ddlFormParentNameClientID = '<%= ddlFormParentName.ClientID %>';
        var cbFormSTATUSClientID = '<%= cbFormSTATUS.ClientID %>';
         var tbxFormICO_PATHClientID = '<%= tbxFormICO_PATH.ClientID %>';
         var tbxFormCODE_PATHClientID = '<%= tbxFormCODE_PATH.ClientID %>';
         var tbxFormSEQ_NOClientID = '<%= tbxFormSEQ_NO.ClientID %>';
         var tbxFormREMARKClientID = '<%= tbxFormREMARK.ClientID %>';

        function onNewButtonClick(event) {
            // 重置表单字段
            F(formClientID).reset();
            F(hfFormIDClientID).setValue(null);
            // 弹出窗体
            F(windowClientID).show();
            F(windowClientID).setTitle('新增数据');
        }

         function onEditButtonClick(event) {
            showEditWindow();
        }

        function showEditWindow(rowId) {
            var grid = F(gridClientID);

            // 如果传入参数为空，则获取当前选中行
            if (!rowId) {
                var selectedRowIds = grid.getSelectedRows();
                if (!selectedRowIds.length) {
                    F.alert('请至少选择一项！');
                    return;
                }

                rowId = selectedRowIds[0];
            }

            
            F(windowClientID).setTitle('编辑数据');

            // 当前行数据
            var rowValue = grid.getRowValue(rowId);

            // 使用当前行数据填充表单字段
            F(hfFormIDClientID).setValue(rowId);
            F(tbxFormMenu_NameClientID).setValue(rowValue['Menu_Name']);
            F(ddlFormParentNameClientID).setValue(rowValue['Parent_ID']);
            F(cbFormSTATUSClientID).setValue(rowValue['STATUS']);
            F(tbxFormICO_PATHClientID).setValue(rowValue['ICO_PATH']);
            F(tbxFormCODE_PATHClientID).setValue(rowValue['CODE_PATH']);
            F(tbxFormSEQ_NOClientID).setValue(rowValue['SEQ_NO']);
            F(tbxFormREMARKClientID).setValue(rowValue['REMARK']);
            // 弹出新增窗体
            F(windowClientID).show();
        }

    </script>
 </body>
</html>